/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pbl_servidor;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.List;

/**
 *
 * @author Asuka
 */
public class RecebeCliente implements Runnable {

    private Socket cliente;
    private ServerSocket servidor;
    private RecebedorServidor recebeServer;
    private PBL_Servidor pbl_serv;
    private List<Socket> listSocketsOnline;
    private TelaServidor  telaServidor;

    public RecebeCliente(ServerSocket servidor, PBL_Servidor pbl_serv, List<Socket> list) {
        this.servidor = servidor;
        this.pbl_serv = pbl_serv;
        this.listSocketsOnline = list;
    }

    @Override
    public void run() {
        while (true) {
            try {
                cliente = servidor.accept();
                System.out.println("Nova conexão com o cliente " + cliente.getInetAddress().getHostAddress());
               // telaServidor.exibeMensagem("\nNova conexão com o cliente " + cliente.getInetAddress().getHostAddress());
                recebeServer = new RecebedorServidor(cliente.getInputStream(), pbl_serv, this.cliente, listSocketsOnline);
                new Thread(recebeServer).start();
                //QuemEstaOnline QeO = new QuemEstaOnline(cliente, pbl_serv, listSocketsOnline);
                //new Thread(QeO).start();
            } catch (IOException ex) {
                System.out.println("erro12: " + ex.getMessage());
            }
        }
    }
}
